import request from '@/utils/request'
import httpRequest from '@/utils/httpRequest.js';
import httpRequest2 from '@/utils/httpRequest2.js';
import { number } from 'echarts/lib/export';

// 查询客户列表
export function listPersonCustomer(query) {
  return request({
    url: '/crm/customer/person-list',
    method: 'get',
    params: query
  })
}

// 查询客户列表
export function listPersonCustomers(query) {
  return request({
    url: '/crm/customer/person-customers',
    method: 'get',
    params: query
  })
}

// 查询客户列表
export function listCustomer(query) {
  return request({
    url: '/crm/customer/list',
    method: 'get',
    params: query
  })
}

// 查询成交客户列表
export function listDealCustomer(query){
  return request({
    url: '/crm/customer/deal-list',
    method: 'get',
    params: query
  })
}

// 查询客户详细
export function getCustomer(id) {
  return request({
    url: '/crm/customer/' + id,
    method: 'get'
  })
}

// 地区
export function getregions(params) {
  return request({
    url: '/crm/customer/region',
    method: 'get',
    params
  })
}

// export function getprovinceName(params) {
//   return request({
//     url: '/crm/customer/region',
//     method: 'get',
//     params
//   })
// }


// 新增客户
export function addCustomer(data) {
  return request({
    url: '/crm/customer',
    method: 'post',
    data: data
  })
}

// 修改客户
export function updateCustomer(data) {
  return request({
    url: '/crm/customer',
    method: 'put',
    data: data
  })
}

// 删除客户
export function delCustomer(id) {
  return request({
    url: '/crm/customer/' + id,
    method: 'delete'
  })
}


//转移客户
export function transferCustomer(data){
  return request({
    url: '/crm/customer/transfer',
    method: 'post',
    params: data
  })
}

//移入公海
export function toPool(data){
  return request({
    url: '/crm/customer/to-pool',
    method: 'post',
    params: data
  })
}


// 下载模板
export const handledownloadApi = () => {
  // return request({
  //   url: '/crm/customer/excel',
  //   method: 'get',
  //   responseType: 'blob'
  // })
  return httpRequest2({
    url:'/factory/v1/jy-crm-app/crm/customer/excel',
    method: 'get',
    responseType: 'blob'
  })
}

//通用文件上传
export function reqFileUpload(fileName,data){
  return httpRequest({
    url: '/api/v1/open/resource/upload/file?fileExtName=' + fileName,
    method: 'post',
    data: data, 
    headers:{
      'Content-Type': 'multipart/form-data',
    }
  })
}
//从服务器下载文件
export const reqFileDownload = (requestUrl) => {
  return httpRequest2({
    url:requestUrl,
    // url:'/crm/customer/excel'+requestUrl,
    method: 'get',
    responseType: 'blob'
  })
}

//我的客户修改弹窗审核按钮
export function getreview(username) {
  return request({
    url: '/system/user/byUserId?username=' + username,
    method: 'get'
  })
}

